<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="author" content="BaiYY"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/page2.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.validate.min.js"></script>
    <style type="text/css">
        .main .input-group-addon{
            width: 120px;
        }
        .form-control{
            -webkit-appearance: none;
        }
    </style>
</head>
<body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
            <li role="presentation"><a href="myNext.html">下级详情</a></li>
            <if condition='$review eq 1'>
                <li role="presentation"><a href="myNextCheck.html">下级审核</a></li>
            </if>
            <li role="presentation" class="active"><a href="myNextSearch.html">下级查询</a></li>
            <if condition='$role lt $player'>
                <li role="presentation" id="playerole"><a href="playerSearch.html">{:L(GAME_SETTING_PLAYER)}</a></li>
            </if>
        </ul>
        <section>
            <div class="row">
                <div class="col-md-6" style="margin-top: 10px;">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="请输入玩家ID" name="uid" id="uid">
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="button" id="btn">&emsp;查看&emsp;</button>
                        </span>
                    </div>
                </div>
                <div class="col-md-6" style="line-height: 50px;position: relative;">
                    <button class="btn btn-primary" id="buyBtn">购买详情</button>
                    <button class="btn btn-primary" id="payBtn">充值详情</button>
                    <if condition='$role eq 1'>
                        <button class='btn btn-primary' onclick="setHandel()">设置</button>
                    </if>
                    <div id="sub_tips" style="position: absolute;top: 45px;left: 185px;">
                        <ul>
                            <li id="special"><span data-toggle="modal" data-target="#kmyModal">{:L(GAME_SETTING_SPECIAL)}</span></li>
                        </ul>
                    </div>
                </div>
            </div>
            <section class="main">
                <div class="row" style="margin-top: 10px;">
                    <div class="col-md-6 text-center">
                        <div class="input-group">
                            <span class="input-group-addon">下级ID&emsp;&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="user_id" id="user_id" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">真实姓名&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="tname" id="tname" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">微信昵称&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="bname" id="bname" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">手机号码&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="tel" id="tel" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">代理级别&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="role" id="role" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">推荐总数&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="total_refer" id="total_refer" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon" id="clubs">{:L(GAME_CLUB_MEMEMBER)}</span>
                            <input class="form-control" type="text" name="clubMemenber" id="clubMemenber" disabled="disabled"  />
                        </div>
                    </div>
                    <div class="col-md-6 text-center">
                        <div class="input-group">
                            <span class="input-group-addon">剩余{:L(GAME_RESOURCE)}&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="card_number" id="card_number" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">总返利额&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="total_rebate" id="total_rebate" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">总消费额&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="total_amount" id="total_amount" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">待提现额&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="total_withdraw" id="total_withdraw" disabled="disabled" />
                        </div>
                        <div class="input-group">
                            <span class="input-group-addon">已提现额&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="total_draw" id="total_draw" disabled="disabled" />
                        </div>

                        <div class="input-group">
                            <span class="input-group-addon">注册时间&emsp;&emsp;</span>
                            <input class="form-control" type="text" name="create_time" id="create_time" disabled="disabled" />
                        </div>
                    </div>
                </div>
            </section>
            <section class="pay" style="display: none;max-width: 800px">
                <div class="table-responsive">
                    <table class="table" id="paylist" style="border: 1px solid #ddd;">
                        <thead>
                        <tr>
                            <th colspan="2">玩家ID</th>
                            <th colspan="2">充值的数量</th>
                            <th colspan="2">充值状态</th>
                            <th colspan="2">充值的时间</th>
                        </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
                <ul class="page" id="page2" style="width: 100%;overflow: hidden;"></ul>
            </section>
            <section class="buy" style="display: none;max-width: 800px">
                <div class="table-responsive">
                    <table class="table" id="buylist" style="border: 1px solid #ddd;">
                        <thead>
                            <tr>
                                <th colspan="2">购买商品名称</th>
                                <th colspan="2">购买商品价格</th>
                                <th colspan="2">购买数量</th>
                                <th colspan="2">购买时间</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
                <ul class="page" id="page1" style="width: 100%;overflow: hidden;"></ul>
            </section>
        </section>
        <div class="modal fade" id="kmyModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabelk">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="exampleModalLabelk">专场图标显示设置</h4>
                    </div>
                    <div class="modal-body" style="padding-top: 0">
                        <div class="row" >
                            <div class="col-md-12">
                                <h3>说明</h3>
                                <p>该设置可控制客户端是否显示{:L(GAME_SESSION)}图标</p>
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="input-group">
                                            <span class="input-group-addon">游戏ID&emsp;</span>
                                            <input type="text" class="form-control" name="uid" id="uidd" disabled="true">
                                        </div>
                                        <div class="input-group">
                                            <span class="input-group-addon">{:L(GAME_SESSION)}图标</span>
                                            <div class="form-control">
                                                <input type="radio" name="privilege" value="1" id="privilege1">显示
                                                <input type="radio" name="privilege" value="0" id="privilege0">不显示
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="pbtn">确定</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            onClick("#buyBtn");
            onClick("#payBtn");
        })
        $(function () {
            var values = $("#playerole").text();
            var clubs = $("#clubs").text();
            var special = $("#special").text();

            if($.trim(values) == '' || $.trim(values) == 'GAME_SETTING_PLAYER') {
                $("#playerole").hide();
            }
            if($.trim(clubs) == '' || $.trim(clubs) == 'GAME_CLUB_MEMEMBER') {
                $("#clubs").parent().hide();
            }
            if($.trim(special) == '' || $.trim(special) == 'GAME_SETTING_SPECIAL') {
                $("#special").hide();
            }
        })
        var user_id = "<?php echo session('adminTel');?>";
        $("#btn").on("click",function () {
            if(!$(".main").show()){
                $(".main").show();
            }
            $(".pay").hide();
            $(".buy").hide();
            var uid = $.trim($("#uid").val());
            if(uid == '' || uid == null){
                alert("请输入要查询的代理ID!");
                return false;
            }else if(isNaN($.trim(user_id))){
                alert("代理ID是数字!");
                window.location.href="{:U('Admin/Main/myNextSearch')}";
                return false;
            }else if(uid == user_id) {
                alert("抱歉，不能输入自己的ID");
                window.location.href="{:U('Admin/Main/myNextSearch')}";
                return false;
            }
            $.ajax({
                type:"get",
                url:"{:U('Admin/Main/myNextSearchh')}?uid="+uid,
                success:function (data) {
                    console.log(data);
                    if(data == 'error') {
                        alert("请求错误！");
                    }else if(data == 'nodata') {
                        alert("抱歉输入的代理无效！");
                    }else{

                        if(data.msg.hasOwnProperty('clubMemberCount')) {
                            $("#clubMemenber").val(data.msg.clubMemberCount);
                        }else{
                            $("#clubMemenber").val('暂无');
                        }

                        if(data.msg.hasOwnProperty('privilege') && data.msg.privilege == 1) {
                            $("#privilege1").attr('checked',true);
                        }else{
                            $("#privilege0").attr('checked',true);
                        }

                        $("#uidd").val(data.agent.user_id);
                        $("#user_id").val(data.agent.user_id);
                        $("#tname").val(data.agent.name);
                        $("#bname").val(data.msg.info.name);
                        $("#tel").val(data.agent.tel);
                        $("#total_rebate").val(data.agent.total_rebate);
                        $("#total_amount").val(data.agent.total_amount);
                        $("#total_withdraw").val((data.agent.total_rebate-data.agent.total_withdraw));
                        $("#total_draw").val(data.agent.total_withdraw);
                        $("#role").val(data.agent_name);
                        $("#total_refer").val(data.count);
                        $("#card_number").val(data.msg.status.card);
                        $("#create_time").val(getLocalTime(data.agent.create_time));
                    }
                }
            });

            $("#buyBtn").on("click",function () {
                $(".main").hide();
                $(".pay").hide();
                $(".buy").show();
                var search = $.trim($("#uid").val());
                if(search == '') {
                    alert("请输入要查询的代理ID！");
                    return false;
                }else if(isNaN(search)) {
                    alert("代理ID是数字!");
                    window.location.href="{:U('Admin/Main/agentUserSearch')}";
                    return false;
                }
                $.ajax({
                    type:"get",
                    url:"{:U('Admin/Main/agentNextBuyDetail')}?user_id=" + search,
                    success:function (buys) {
//                        console.log(buys);
                        if(buys == 'error') {
                            alert("暂无记录！");
                        }else{
                            options={
                                "id":"page1",//显示页码的元素
                                "data":buys,//显示数据
                                "maxshowpageitem":2,//最多显示的页码个数
                                "pagelistcount":10,//每页显示数据个数
                                "callBack":function(res){
                                    var str = '';
                                    for(var i=0;i<res.length;i++) {
                                        str += "<tr><td colspan='2'>"+res[i].goods_name+"</td><td colspan='2'>"+res[i].amount+"</td><td colspan='2'>"+res[i].number+"</td><td colspan='2'>"+getLocalTime(res[i].add_time)+"</td></tr>";
                                    }
                                    $("#buylist tbody").html(str);
                                }
                            }
                            page.init(buys.length,1,options);
                        }
                    }
                })
            });

            $("#payBtn").on("click",function(){
                $(".main").hide();
                $(".buy").hide();
                $(".pay").show();
                var search = $.trim($("#uid").val());
                if(search == '') {
                    alert("请输入要查询的代理ID！");
                    return false;
                }else if(isNaN(search)) {
                    alert("代理ID是数字!");
                    window.location.href="{:U('Admin/Main/agentUserSearch')}";
                    return false;
                }
                $.ajax({
                    type:"get",
                    url:"{:U('Admin/Main/agentNextPayDetail')}?user_id=" + search,
                    success:function (pays) {
//                        console.log(pays);
                        if(pays == 'error') {
                            alert("暂无记录！");
                        }else{
                            option={
                                "id":"page2",//显示页码的元素
                                "data":pays,//显示数据
                                "maxshowpageitem":2,//最多显示的页码个数
                                "pagelistcount":10,//每页显示数据个数
                                "callBack":function(res) {
                                    var str = '';
                                    var txt = '';
                                    for(var i=0;i<res.length;i++) {
                                        if(res[i].status == '1') {
                                            txt = '成功';
                                        }else if(res[i].status == '0') {
                                            txt = '失败';
                                        }
                                        str += "<tr><td colspan='2'>"+res[i].uid+"</td><td colspan='2'>"+res[i].number+"</td><td colspan='2'>"+txt+"</td><td colspan='2'>"+getLocalTime(res[i].add_time)+"</td></tr>";
                                    }
                                    $("#paylist tbody").html(str);
                                }
                            }
                            page2.init(pays.length,1,option);
                        }
                    }
                });
            });
        })

        $("#pbtn").on("click",function () {
            var privilege = $("input[name='privilege']:checked").val();
            var uid = $("#uidd").val();
            $.ajax({
                type:'post',
                url:"{:U('Admin/Main/uidPrivSet')}?",
                dataType:"json",
                data:{"uid":uid,"privilege":privilege},
                success:function (data) {
                    if(data == 'success') {
                        alert("设置成功！");
                        $("#kmyModal").hide();
                        $(".modal-backdrop").hide();
                    }else if(data == 'failure'){
                        alert("请求错误！");
                        window.location.href="{:U('Admin/Main/myNextSearch')}";
                    }else if(data == 'error') {
                        alert("设置失败！");
                        window.location.href="{:U('Admin/Main/myNextSearch')}";
                    }
                }
            });
        });
        function setHandel() {
            $("#sub_tips").toggle();
            $("#sub_tips").on("click",function () {
                $(this).hide();
            })
        }

        function onClick(obj) {
            $(obj).on("click",function () {
                var uid = $.trim($("#uid").val());
                if(uid == '' || uid == null) {
                    alert("请输入要查询的代理ID!");
                }
            })
        }

    </script>
</body>
</html>